<?
/**
 * vim: et ts=4 sts=4 sw=4 fdm=marker
 *
 * 编辑器----上传文件
 *
 * @author    wang Penghai <china_php@hotmail.com>
 * @copyright 2008 5e6d Corporation.
 * @version   $Id:$
 */

include_once('../common.php');
include_once ED_APP_LIB_PATH . 'ed_lib_upload.class.php';

$upload = new ed_lib_upload;
$type = array('jpg','gif','png',);
$upload->set_upload_type($type);
$upload_info = $upload->upload($_FILES['FILE_UPLOAD'], 'images', 0,$f_r_id =0);
if (false === $upload_info) {
	$error_info = $upload->get_error_info();
	switch($error_info['code']) {
		case '107000':
			$uploadStat = '此类型不允许上传！';
			break;
		case '107001':
			$uploadStat = '文件大小超过了10M！';
			break;
		default:
			$uploadStat = '系统错误， 不允许上传！';
			break;
	}
    
    echo '<meta http-equiv=content-type content="text/html; charset=UTF-8"><title>';
    echo "<script>";
    echo "alert('$uploadStat');";
    echo "</script>";
} else {
	$file_path = PATH_WEB_UPLOAD . $upload_info['f_filename'];
    echo "<script>";
    echo "parent.document.getElementById('imgUrl').value = '$file_path';";
    echo "parent.document.getElementById('fileupload').value = '';";
    echo "parent.createImg();";
    echo "</script>";
}
exit();
